<?php
/**
 * Created by PhpStorm.
 * User: kongqi
 * Date: 2019/11/24
 * Time: 15:51
 */

namespace App\Plugin\HostServer\Admin;


use App\Plugin\HostServer\Models\PnHostSvUser;
use Illuminate\Validation\Rule;

class UserController extends BaseController
{
    public function setModel()
    {
        $this->model = new PnHostSvUser();
    }
    public function checkRule($id = '')
    {
        if (!$id) {
            return [
                'name'=>'required',
                'email' => [
                    'required',
                    "email",
                    Rule::unique('pn_host_sv_users', 'email')
                ]
            ];
        }

        return [
            'name'=>'required',
            'email' => [
                "required",
                "email",
                Rule::unique('pn_host_sv_users', 'email')->ignore($id, 'id')
            ]

        ];
    }
}